<?php

function ligneMateriel($donnees1)
{
    echo <<<END
    <tr id="materiel_{$donnees1['id']}">
        <td>
            <a class="edition" href="index.php?page=materiel&amp;id_matos={$donnees1['id']}">{$donnees1['nom']}</a>
        </td>
END;

    $requete2 = "SELECT Pret.*, User.nom, User.prenom FROM Pret LEFT JOIN User ON User.pseudo=Pret.emprunteur WHERE materiel=\"{$donnees1['id']}\" ORDER BY date_emprunt DESC LIMIT 0,1";
    $reponse2 = executerRequete($requete2, $GLOBALS["debug"]);

    if ($donnees2 = mysql_fetch_array($reponse2) and $donnees2['date_retour']==0)
    {

        $date_emprunt = date('d/m/Y \(H\hi\m\i\ns\s\)',convertirDate($donnees2['date_emprunt']));
        echo <<<END
        <td><a class="edition" href="index.php?page=user&pseudo={$donnees2['emprunteur']}">{$donnees2['prenom']} {$donnees2['nom']}</a></td>
        <td>{$date_emprunt}</td>
        <td>
            <a class="rendreMateriel rendreMateriel_{$donnees1['id']}" href="index.php?page=gestionMateriel&amp;action=rendre&amp;id={$donnees2['id']}">Rendre</a>
            <a class="edition" href="index.php?page=updateMateriel&supprimer={$donnees1['id']}">Supprimer</a>
        </td>
    </tr>
END;

    }
    else
    {

        echo <<<END
        <td>
<form name="emprunt_{$donnees1['id']}" class="emprunt" method="post" action="index.php?page=gestionMateriel&amp;action=emprunter">
            <input name="emprunteur" class="emprunteur" type="text"/>

            <input name="id_matos" type="hidden" value='{$donnees1['id']}' />
            <input type="submit" value="Emprunter"/>
</form>
        </td>
        <td>
        </td>
        <td>
            
            <a class="edition" href="index.php?page=updateMateriel&supprimer={$donnees1['id']}">Supprimer</a>
        </td>
    </tr>
END;
    }
}

?>
